<template>
	<!-- <TableModal ref='tableModalRef' :config='config' :search='searchConfig' :table='tableConfig'/> -->
</template>

<script setup>
	/* --------------------------- Component --------------------------- */
	// const TableModal 	= $.lazy(()=>import('#cpt/temp/TableModal.vue'))
	/* ---------------------------  ref --------------------------- */
	// ref: tableModalRef
	/* --------------------------- Event --------------------------- */
	const emit = defineEmits(['select'])
	/* --------------------------- config --------------------------- */
	const config = {
		modalWidth: '90%',
		modalHeight: '80%',
		title: '选择产品',
		// drawer: true,
		footer: false
	}
	/* ---------------------------  搜索 Search --------------------------- */
	ref: productBandTypeData = []
	const searchConfig = {
		data: [
			{ label:'产品名称', 		name:'productName' },
			{ label:'产品类型', 		name:'prodTypeId', 	r:1, type:'tree-select', idStr:'prodTypeId', nameStr:'prodTypeName', api:'business/product/type/list', mul:false},
			{ label:'产品频段', 		name:'productBandType', type:'select', api:'system/dict/data/type/business_common_productBandType', param:1, idStr:'dictValue', nameStr:'dictLabel' ,
				getData: data => productBandTypeData = data
			},
		]
	}
	/* ---------------------------  Table --------------------------- */
	const tableConfig = {
		api 		: 'business/product/list',
		cols 		: [
			{ title: '序号', 		dataIndex: 'seqNum', 			...$fn.table.seqNum },
			// { title: '产品名称', 	dataIndex: 'productName', 		width:150, customRender:({ text, record }) => $fn.table.popDetail({ tableRef, id:record.productId, config:listConfig, text }) },
			{ title: '产品型号', 	dataIndex: 'productModel', 		width:150 },
			{ title: '产品名称', 	dataIndex: 'productName', 		width:150 },
			{ title: '业务类别', 	dataIndex: 'businessType', 		width:150 },
			{ title: '产品类别', 	dataIndex: 'productType', 		width:150 },
			{ title: '是否即征即退', 	dataIndex: 'isTaxReturn', 		...$fn.table.six, customRender:({ text }) => text === 'Y' ? '是' : '否' },
			{ title: '产品频段', 	dataIndex: 'productBandType', 	...$fn.table.four, customRender:({ text }) => $fn.getState(productBandTypeData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '单价', 		dataIndex: 'price', 			...$fn.table.money },
			{ title: '单位', 		dataIndex: 'units', 			...$fn.table.four },
			{ title: '产品负责人', 	dataIndex: 'chargeMan', 		...$fn.table.name },
			{ title: '图片', 		dataIndex: 'piturePath', 		...$fn.table.img },
			{ title: '创建人', 		dataIndex: 'createByCN', 			...$fn.table.name },
			{ title: '创建时间', 	dataIndex: 'createTime', 		...$fn.table.time },
			{ ...$fn.table.control, width:100 }
		],
		controls 	: rows => [
			{ label:'选择产品', click:()=> {
				if(rows){
					emit('select', rows)
					window.$tableModalRef().close()
				}
			} }
		]
	}
	/* --------------------------- 通信 --------------------------- */
	defineExpose({
		open: () => window.$tableModalRef().open({ config, table:tableConfig, search:searchConfig })
	})
</script>
